package auctions;

import jade.core.Agent;
import jade.core.behaviours.SimpleBehaviour;

import jade.domain.FIPANames;

import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;

public class InterfaceBehviour extends SimpleBehaviour {
    static MessageTemplate template = MessageTemplate.not(
        MessageTemplate.or(MessageTemplate.MatchProtocol(
            FIPANames.InteractionProtocol.FIPA_DUTCH_AUCTION),
                           MessageTemplate.MatchProtocol(
            FIPANames.InteractionProtocol.FIPA_ENGLISH_AUCTION)));
    
    public InterfaceBehviour(Agent agent) {
        super(agent);
    }

    public InterfaceBehviour() {
        super();
    }

    public void action() {
        ACLMessage msg = myAgent.receive(template);
        if(msg != null) {
                String senderName = msg.getSender().getLocalName();
                ((SellerAgent)myAgent).updateBuyer(senderName, 
                                                   msg.getContent());
        } else {
            block();
        }
    }

    public boolean done() {
        return false;
    }
}
